
import axios from 'axios'
import qs from 'qs'

if (process.env.NODE_ENV == 'development') {
  axios.defaults.baseURL = '/wf'
}
axios.defaults.withCredentials = false
axios.defaults.headers = {
  'X-Requested-With': 'XMLHttpRequest',
}

// global variable
const global = {
  username: localStorage.getItem("username"),
  userList: []
}

// init
var initListUser = async function() {
  await axios.post('/access/list').then(resp => {
    var res = resp.data || {}
    if (res.data && res.data.length) {
      global.userList = res.data
      global.username = global.username || res.data[0]
    }
  })
}
initListUser()

export default global